// pages/management/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
         currentPage: 'all',
        // subPage: 'permission',
        currentMenu: 'all',
        currentMenuName: '用户',
        currentSubMenus: [],
        menuData: [
            {
                id: 'all',
                name: '全部管理',
                icon: '/images/setting.png',
                subMenus: [
                    { id: 'role', name: '身份管理', icon: '/images/identity.png', url: 'role' },
                    { id: 'adminlist', name: '账户列表', icon: '/images/list.png', url: 'adminlist' },
                    { id: 'userlist', name: '用户列表', icon: '/images/permission.png', url: 'userlist' },
                    { id: 'orderSystem', name: '订单管理', icon: '/images/order1.png', url: 'orderSystem' },
                    { id: 'report', name: '交易数据', icon: '/images/report.png', url: 'report' },
                    { id: 'afterSale', name: '售后管理', icon: '/images/afterSale.png', url: 'afterSale' },
                    { id: 'withdraw', name: '提现管理', icon: '/images/withdraw.png', url: 'withdraw' },
                    // {id:'coupon',name:'优惠券管理',icon:'/images/coupon.png',url:'coupon'},
                    { id: 'category', name: '类目管理', icon: '/images/category.png', url: 'category' },
                    { id: 'sku', name: 'sku管理', icon: '/images/sku.png', url: 'sku' },
                    { id: 'dislist', name: '分店列表', icon: '/images/list.png', url: 'dislist' },
                    { id: 'disSettings', name: '分销设置', icon: '/images/setting.png', url: 'disSettings' },
                    { id: 'orderBoard', name: '派单池', icon: '/images/orderBoard.png', url: 'orderBoard' },
                    { id: 'delivery-manager', name: '配送员管理', icon: '/images/list.png', url: 'delivery-manager' },
                ]
            },
            {
                id: 'user',
                name: '账户管理',
                icon: '/images/user.png',
                subMenus: [
                    { id: 'role', name: '身份管理', icon: '/images/identity.png', url: 'role' },
                    { id: 'adminlist', name: '账户列表', icon: '/images/list.png', url: 'adminlist' },
                    { id: 'userlist', name: '用户列表', icon: '/images/permission.png', url: 'userlist' }
                ]
            }, {
                id: 'payment',
                name: '交易管理',
                icon: '/images/payment.png',
                subMenus: [
                    { id: 'orderSystem', name: '订单管理', icon: '/images/order1.png', url: 'orderSystem' },
                    { id: 'report', name: '交易数据', icon: '/images/report.png', url: 'report' },
                    { id: 'afterSale', name: '售后管理', icon: '/images/afterSale.png', url: 'afterSale' },
                    { id: 'withdraw', name: '提现管理', icon: '/images/withdraw.png', url: 'withdraw' },
                    // {id:'coupon',name:'优惠券管理',icon:'/images/coupon.png',url:'coupon'}
                ]
            }, {
                id: 'product',
                name: '商品管理',
                icon: '/images/product.png',
                subMenus: [
                    { id: 'category', name: '类目管理', icon: '/images/category.png', url: 'category' },
                    { id: 'sku', name: 'sku管理', icon: '/images/sku.png', url: 'sku' },
                    // { id: 'userlist', name: '用户列表', icon: '/images/permission.png', url: 'userlist' }
                ]
            }
            , {
                id: 'promotion',
                name: '分销管理',
                icon: '/images/promotion.png',
                subMenus: [
                    { id: 'dislist', name: '分店列表', icon: '/images/list.png', url: 'dislist' },
                    { id: 'disSettings', name: '分销设置', icon: '/images/setting.png', url: 'disSettings' },
                    // { id: 'userlist', name: '用户列表', icon: '/images/permission.png', url: 'userlist' }
                ]
            }, {
                id: 'activity',
                name: '配送管理',
                icon: '/images/activity.png',
                subMenus: [
                    { id: 'orderBoard', name: '派单池', icon: '/images/orderBoard.png', url: 'orderBoard' },
                    { id: 'delivery-manager', name: '配送员管理', icon: '/images/list.png', url: 'delivery-manager' },
                    // { id: 'userlist', name: '用户列表', icon: '/images/permission.png', url: 'userlist' }
                ]
            },
            // 其他菜单项...
        ]
    },
    navigateToSubPage(e) {
        const url = e.currentTarget.dataset.url
        wx.navigateTo({
            url: `/packageA/pages/${url}/index`
        })
    },
    // navigateTo: function (e) {
    //     const url = e.currentTarget.dataset.url;
    //     this.setData({
    //         currentPage: url
    //     });

    //     // 实际开发中这里应该跳转到对应页面
    //     // wx.navigateTo({
    //     //   url: '/pages/' + url + '/index'
    //     // });
    // },
    navigateTo: function (e) {
        const url = e.currentTarget.dataset.url;
        console.log(url);
        let myid = 0;
        switch (url) {
            case 'all':
                myid = 0;
                break;
            case 'user':
                myid = 1;
                break;
            case 'payment':
                myid = 2;
                break;
            case 'product':
                myid = 3;
                break;
            case 'promotion':
                myid = 4;
                break;
            case 'activity':
                myid = 5;
                break;
            default:
                myid = 0;
                break;
        }
        this.setData({
            currentPage: url,
            currentSubMenus: this.data.menuData[myid].subMenus
        });

        // 实际开发中这里应该跳转到对应页面
        // wx.navigateTo({
        //   url: '/pages/' + url + '/index'
        // });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            currentSubMenus: this.data.menuData[0].subMenus
        })
        // 初始化数据
        //  this.getTabBar().setData({
        //     selected: 0
        //   });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})